<?php
class Default_Model_Role extends Zend_Db_Table_Abstract {
    protected $_name = 'role';
    
    public function getDataByUser($userId, $gameId){
        $query = $this->select()
            ->setIntegrityCheck(false)
            ->from(array('r' => $this->_name))
            ->join(array('ur'=>'user_role'),"r.roleId = ur.roleId")
            ->where('ur.userId=?',$userId)
            ->where('r.gameId like \'%"'.$gameId.'"%\'');
            //->where("status = ?",1);
            
        return $this->fetchAll($query);
    }
    public function getAllData($option){
        $query = $this->select()
            ->setIntegrityCheck(false)
            ->from(array('ur' => 'user_role'))
            ->join(array('r' => 'role'),'ur.roleId = r.roleId',array('gameId'));
        if($option['userId']){
            $query->where('ur.userId=?',$option['userId']);
        }
            //->where("status = ?",1);

        return $this->fetchAll($query);
    }
}